//
//  UIScrollView+InfiniteScroll.m
//  MengLiao
//
//  Created by xiuxin on 2022/7/15.
//  Copyright © 2022 BaseBusiness. All rights reserved.
//

#import "UIScrollView+InfiniteScroll.h"

@implementation UIScrollView (InfiniteScroll)
- (void)pullupHeaderRefresh:(void (^)(void))headerBlock{
    MJRefreshHeader *mj_Header = self.mj_header;
    if (!mj_Header) {
       MJRefreshNormalHeader *mj_Header = [MJRefreshNormalHeader headerWithRefreshingBlock:headerBlock];
       mj_Header.lastUpdatedTimeLabel.hidden = YES;
//       mj_Header.stateLabel.hidden = YES;
       [mj_Header setTitle:@"正在加载中,请稍后" forState:MJRefreshStateRefreshing];

        if ([self isKindOfClass:NSClassFromString(@"KDDCollectionView")] || [self isKindOfClass:UICollectionView.class]) {
            mj_Header.isCollectionViewAnimationBug = YES;
        }
       self.mj_header = mj_Header;
    }
}
- (MJRefreshFooter *)pullDownFootRefresh:(void (^)(void))footerBlock{
    MJRefreshFooter *mj_footer = self.mj_footer;
    if (!mj_footer) {
        MJRefreshAutoNormalFooter * mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:footerBlock];
        [mj_footer setTitle:@"" forState:MJRefreshStateIdle];
        [mj_footer setTitle:@"" forState:MJRefreshStatePulling];
        [mj_footer setTitle:@"正在加载中,请稍后" forState:MJRefreshStateRefreshing];
        [mj_footer setTitle:@"" forState:MJRefreshStateWillRefresh];
        [mj_footer setTitle:@"没有更多了~" forState:MJRefreshStateNoMoreData];
        mj_footer.stateLabel.textColor = ColorFromHex(0xcccccc);

        mj_footer.triggerAutomaticallyRefreshPercent = -20.0f;
        self.mj_footer = mj_footer;
    }
    return mj_footer;
}
@end
